<template>
  <div class="form-group" style="padding-right:30px;">
    <div class="row">
      <div class="col-xs-12 buttom_margin">
        <span>期間条件</span>
      </div>
      <div class="col-xs-12">
        <select name="timeType" class="form-control input-sm" v-model="dateType">
          <option value="kuaijimonth" selected>会計月</option>
          <option value="ziranmonth" >カレンダー月</option>    
          <option value="week">年週</option>
          <option value="day">日付</option>
        </select>
      </div>
      <div class="col-xs-12">
        <mdldateComponent
              :dateInfo="this.dateObj.dateArray[0]"
              :dateType="this.dateObj.dateType"
              class="input-sm"
            ></mdldateComponent>
      </div>
    </div>
  </div>
</template>
<script>
import mdldateComponent from "@/components/mdl_date.vue";
export default {
  name: "mdltimeCondition",
  components: {
    mdldateComponent: mdldateComponent
  },
  props: {
    dateObj: {
      type: Object
    },
    companyValue: {
      type: String
    }
  },
  data: function() {
    return {
      timeStr: "",
      fasicalFlag: true
    };
  },
  computed: {
    //用于设置/返回时间类型的数据
    dateType: {
      get: function() {
        return this.dateObj.dateType;
      },
      set: function(value) {
        this.$set(this.dateObj, "dateType", value);
      }
    }
  },
  watch: {
    "dateObj.dateCondition"() {

    },
    "dateObj.dateType"() {
      for (var i = 0; i < this.dateObj.dateArray.length; i++) {
        this.dateObj.dateArray[i].dateType = this.dateObj.dateType;
      }
    }
  },
  created() {
    this.dateType='kuaijimonth'
    var yTimeDate = new Date(new Date().getTime() - 24 * 60 * 60 * 1000);
    var month = yTimeDate.getMonth() + 1;
    var yTime =
      "" +
      yTimeDate.getFullYear() +
      (month.toString().length < 2 ? "0" + month : month) +
      (yTimeDate.getDate().toString().length < 2
        ? "0" + yTimeDate.getDate()
        : yTimeDate.getDate());
    this.timeStr = yTime + "~" + yTime;
  }
};
</script>
<style scoped>
span {
  font-weight: normal;
}
.left_margin {
  margin-left: 10px;
}
.hideCondition {
  display: none;
}
.buttom_margin {
  margin-bottom: 10px;
}
</style>